﻿/**
 * ...
 * @author aboutwhat
 */

package bloom.lang;


class Assert 

{

    private static inline function doAssert (expr : Bool, assertId : String, ?message : String) 
    {
        #if (debug||assert)
		if (!expr) throw assertId + " failed: " + message;
		#end
    }
    
	public static inline function assert (expr:Bool, ?message:String):Void 
	{
		doAssert(expr, "assert", message);
	}
    
    public static inline function assertEquals <T>(a:T, b:T, ?message:String):Void 
	{
        
		doAssert(a == b, "assertEquals", message);
	}
    
    public static inline function assertNotNull <T>(a:T, ?message:String):Void 
	{
		doAssert(a != null, "assertNotNull", message);
	}
    
    public static inline function assertInRange (value : Float, min : Float, max : Float, ?message : String) {
        doAssert( min <= value && value <= max, "assertInRange", message);
    }
	
    public static inline function assertFalse (expr:Bool, ?message:String):Void 
	{
		doAssert(!expr, "assertFalse", message);
	}
    
    
        
    
}